<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /><!-- 控制浏览器文件模式为IE8 -->
<title>角色權限修改</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="js/artDialog/skins/default.css" rel="stylesheet" type="text/css" />
<link href="css/sele.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/artDialog/artDialog.js?skin=blue"></script>
<script src="js/artDialog/plugins/iframeTools.js"></script>
<script type="text/javascript" src="js/operamasks-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/elegant/om-all.css" />
<script> 
(function (config) {
    config['lock'] = true;
    config['fixed'] = true;
    config['okVal'] = 'Ok';
    config['cancelVal'] = 'Cancel';
})(art.dialog.defaults);
</script>
<script language="javascript">
	var j = jQuery.noConflict();
	j.ajaxSetup({
		cache:false,
		async: false
	});
</script>
<script>
function submitForm() {
	var name=document.getElementById("roleName").value;
	var code=document.getElementById("roleCode").value;
	var flag=true;
	if(name==null || name=="")
	{
		document.getElementById("roleName").focus();
		art.dialog.tips('角色名称不能为空！', 1.5);
		flag=false;
		return;	
	}
	if(code==null || code=="")
	{
		document.getElementById("roleCode").focus();
		art.dialog.tips('角色代码不能为空！', 1.5);
		flag=false;
		return;
	}
	if(flag)
	{
		document.forms[0].submit();
	}
}
function selectAll(obj)
{
	var length=obj.id.length;
	var checkbx = j(":checkbox");
	if(obj.checked)
	{
		//全选
		for(var i=0;i<checkbx.length;i++)
		{
			if(checkbx[i].id.length>length)
			{
				var str=checkbx[i].id.substring(0,length);
				if(str==obj.id)
				{
					checkbx[i].checked=true;
				}
			}
		}
	}
	else{
		//全取消
		for(var i=0;i<checkbx.length;i++)
		{
		if(checkbx[i].id.length>length)
			{
				var str=checkbx[i].id.substring(0,length);
				if(str==obj.id)
				{
					checkbx[i].checked=false;
				}
			}
		}
	}
}
</script>
</head>
<body>

	<div class="place">
	    <span>位置：</span>
	    <ul class="placeul">
	    <li>首页</li>
		<li>系统管理</li>
	    <li><a href="#" onclick="javascript:window.location.href='./adminRole.do?action=list'"> 角色權限管理</a></li>
		<li>修改權限</li>
	    </ul>
    </div>
    <div class="rightinfo">
		<form id="form1" action="./adminRole.do?action=edit" method="post">

			<ul class="seachform">
				<li>
					<label>角色名称：</label>
					<input id="roleName" type="text" disabled="disabled" name="roleName" size="10" value="${role.roleName }" style="width:200px;height:32px;" class="scinput" autocomplete="off"/>
					<input type="hidden" value="${role.roleId }" name="roleId"/>
				</li>
				<li>
					<label>角色代码：</label>
				    <input id="roleCode" disabled="disabled" type="text" name="code" size="10" value="${role.roleCode }" style="width:100px;height:32px;"/>
				</li>
				<li>
					<label>角色描述：</label>
					<input id="roleDesc" type="text" name="description" size="10" value="${role.description }" style="width:265px;height:32px;" class="scinput" autocomplete="off"/>
				</li>
			</ul>
			<table class="tablelist">
				<thead>
					<tr>
						<td>功能</td>
            			<td>说明</td>
            			<td>权限</td>
					</tr>
				</thead>
				<tbody>
				<c:forEach var="list" items="${firstMenuList}">
					<tr style="background: #D8E5F2;">
						<td width="25%" ><div style="float: left;">${list.function.functionName}</div></td>
						<td>${list.function.description }</td>
						<td><input type="checkbox" style="width:20px;" name="functionId" onclick="selectAll(this);" value="${list.function.functionId }" id="${list.function.functionCode }" <c:if test="${list.isSelect=='1' }">checked="checked"</c:if>/></td>
			        </tr>
					<c:if test="${list.secondMenuSize>0}">
		          		<c:forEach var="secondList" items="${list.secondMenuList}">
		          			<tr style="background: #EDF6FA;">
		          				<td width="20%"><div style="padding-left:40px;">${secondList.function.functionName}</div></td>
		          				<td>${secondList.function.description }</td>
		          				<td><input type="checkbox" style="width:20px;" id="${secondList.function.functionCode }"  name="functionId" <c:if test="${secondList.thirdMenuSize!=0}">onclick="selectAll(this);"</c:if> <c:if test="${secondList.isSelect=='1' }">checked="checked"</c:if> value="${ secondList.function.functionId}"/></td>
		          			</tr>
		          			<c:if test="${secondList.thirdMenuSize>0}">
		          				<c:forEach var="thirdList" items="${secondList.thirdMenuList}">
		          					<tr>
		          						<td width="25%"><div style="padding-left:80px;">${thirdList.function.functionName }</div></td>
		          						<td>${thirdList.function.description }</td>
		          						<td><input type="checkbox" style="width:20px;" name="functionId" id="${thirdList.function.functionCode }" value="${thirdList.function.functionId }" <c:if test="${thirdList.isSelect=='1' }">checked="checked"</c:if>/></td>
		          					</tr>
		          				</c:forEach>
		          			</c:if>
		          		</c:forEach>
		          	</c:if>
		        </c:forEach>
				</tbody>
			</table>
          	<ul class="forminfo" style="margin-top:30px;">
			    <li>
					<label>&nbsp;</label>
					<input name="" type="button" id="save" onclick="submitForm();" class="btn" value="确定修改"/> 
					<input style="margin-left:100px;" onclick="javascript:document.location.href = './adminRole.do?action=list';" type="button" class="cancel" value="取消修改" />
				</li>
		    </ul>   
	    </form>
	</div>
</body>
<script type="text/javascript">
window.onload=function()
{
	var isAddSuccess = '${isAddSuccess}';
	if(isAddSuccess=="success")
	{
		j.omMessageBox.alert({
	           content:'修改角色成功！',
	           onClose:function(v){
	        	   document.location.href = './adminRole.do?action=list';
	           }
	       });
	}
	else if(isAddSuccess=="error")
	{
		j.omMessageBox.alert({
	           content:'修改角色失败！',
	           onClose:function(v){
	           }
	       });
	}
};
</script>
</html>